import { param2Obj } from '@/utils'

const userMap = {
  dba: {
    token: 'dba',
    introduction: '我是DBA',
    avatar: 'https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif',
    name: 'dba',
    roles: ['dba']
  },
  owner: {
    token: 'owner',
    introduction: '我是系统owner',
    avatar: 'https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif',
    name: '系统owner',
    roles: ['owner']
  },
  member: {
    token: 'member',
    introduction: '我是member',
    avatar: 'https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif',
    name: 'member',
    roles: ['member']
  }
}

export default {
  loginByUsername: config => {
    const { username } = JSON.parse(config.body)
    return userMap[username]
  },
  getUserInfo: config => {
    const { token } = param2Obj(config.url)

    if (userMap[token]) {
      return userMap[token]
    } else {
      return false
    }
  },
  logout: () => 'success'
}
